/**
 * Created by leiweibo on 8/14/15.
 */

var app = angular.module('materialdtlcontroller', []);
app.filter('offset', function () {
  return function (input, start) {
    start = parseInt(start, 10);
    return input.slice(start);
  };
});

app.controller('MaterialDtlCtrl', function ($scope, $routeParams, MaterialService) {
  var id = $routeParams.param;
  MaterialService.getDetail(id, function(res) {
    if (res.result == true) {
      var data = res.material;
      $scope.id = data._id;
      $scope.title = data.title;
      $scope.author = data.author;
      $scope.content = data.content;
      $scope.update_time = data.update_time;
      $scope.attachments = data.attachments;

    } else {
      $scope.error_msg = res.message;
    }
  });

  $scope.cancel = function() {
    window.location = '#/material_list';
  }
});